#include "Scene07.hpp"

Scene07::Scene07() {
    b2Vec2 vertices[16];
    vertices[0].Set(-6.85, -4.0f);
    vertices[1].Set(-0.85, -4.0f);
    vertices[2].Set(-0.85f, -5.0f);
    vertices[3].Set(0.15f, -5.0f);
    vertices[4].Set(0.15f, -4.0f);
    vertices[5].Set(6.85f, -4.0f);
    vertices[6].Set(6.85f, -2.0f);
    vertices[7].Set(4.85f, -2.0f);
    vertices[8].Set(4.85f, 4.0f);
    vertices[9].Set(0.5f, 4.0f);
    vertices[10].Set(0.5f, 4.5f);
    vertices[11].Set(-1.2f, 4.5f);
    vertices[12].Set(-1.2f, 4.0f);
    vertices[13].Set(-4.85f, 4.0f);
    vertices[14].Set(-4.85f, -2.0f);
    vertices[15].Set(-6.85f, -2.0f);

    this->createRoom(7, vertices, 16);

    b2Vec2 platform1Vertices[2];
    platform1Vertices[0].Set(0.85f, 2.0f);
    platform1Vertices[1].Set(0.85f, -2.0f);

    this->createPlatform(platform1Vertices, 2);

    b2Vec2 platform2Vertices[2];
    platform2Vertices[0].Set(0.85f, 0.0f);
    platform2Vertices[1].Set(4.85f, 0.0f);

    this->createPlatform(platform2Vertices, 2);

    b2Vec2 platform3Vertices[2];
    platform3Vertices[0].Set(-0.85f, -4.0f);
    platform3Vertices[1].Set(0.15f, -4.0f);

    this->createPlatform(platform3Vertices, 2);

    this->start = this->createDoor(-4.85f, -3.0f, -1.0f);
    this->createExit(5.85f, -3.0f);
    this->hero = this->createHero(-6.85f + HeroElement::WIDTH / 2.0f, -4.0f + HeroElement::HEIGHT / 2.0f);

    // First light.
    SpotlightElement* firstLight = this->createSpotlight(-0.35f, -4.5f, b2_pi / 2.0f, b2_pi / 7.0f, 9.0f, LightElement::repulsiveLight);
    firstLight->supportBarDirection->Set(0.0f, -1.0f);
    SwitchElement* firstLightSwitch = this->createSwitch(-2.0f, -4.0f, 0.0f, firstLight);
    this->createBox(-0.35f, -3.5f);

    // Second light.
    SpotlightElement* secondLight = this->createSpotlight(3.35f, -0.5f, 7.0f * b2_pi / 10.0f, b2_pi / 5.0f, 7.5f, LightElement::repulsiveLight);
    secondLight->supportBarDirection->Set(1.0f, 0.0f);
    this->createSwitch(3.85f, 0.0f, 0.0f, secondLight);

    // First door.
    DoorElement* firstDoor = this->createDoor(0.85f, -3.0f, 0.0f);
    this->createSwitch(-0.35f, 4.5f, b2_pi, firstDoor);
    this->createBox(2.35f, 0.5f);

    // Exit door.
    this->exit = this->createDoor(4.85f, -3.0f, 1.0f);
    this->exit->setState(false);
    firstLightSwitch->addActionableElement(this->exit);
    this->createBox(2.85f, -3.5f);
}
